package com.hw.ssh.controller;

import com.hw.ssh.entity.User;
import com.hw.ssh.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class PublicController {
    @Autowired
    private UserService userService;

    @RequestMapping("list")
    @ResponseBody
    public List<User> index() {
        return userService.list();
    }
    @RequestMapping("add")
    @ResponseBody
    public List<User> add(User user) {
        userService.add( user );
        return userService.list();
    }

}
